
#include "qyFile.h"
#include "qyFileSystem.h"

//-----------------------------------------------------------------------
qyFile::qyFile()
: m_filename( "" )
, m_pMemChunk( NULL )
, m_sizeChunkByByte( 0 )
{

}

//-----------------------------------------------------------------------
qyFile::qyFile( const qyString &filename )
: m_filename( filename )
, m_pMemChunk( NULL )
, m_sizeChunkByByte( 0 )
{	
}

//-----------------------------------------------------------------------
qyFile::~qyFile()
{
	FreeMemChunk();
}

//-----------------------------------------------------------------------
void * qyFile::AllockMemChunk( size_t memSizeByByte )
{
	if ( m_pMemChunk == NULL )
		FreeMemChunk();
	m_sizeChunkByByte = memSizeByByte + 1;
	m_pMemChunk = malloc( m_sizeChunkByByte + 1);
	return m_pMemChunk;
}

//-----------------------------------------------------------------------
void * qyFile::GetMemChunk()
{
	return m_pMemChunk;
}

//-----------------------------------------------------------------------
void qyFile::FreeMemChunk()
{
	if ( m_pMemChunk != NULL )
	{
		free( m_pMemChunk );
		m_pMemChunk = NULL;
		m_sizeChunkByByte = 0;
	}
}

//-----------------------------------------------------------------------
size_t qyFile::GetChunkSizeByByte() const
{
	return (m_sizeChunkByByte - 1);
}
